import { createStore } from 'vuex'

export default createStore({
  state: {
    // playList:[{al:[]}],
    playList:localStorage.playList?JSON.parse(localStorage.playList):[{al:[]}],
    playIndex:localStorage.playIndex?JSON.parse(localStorage.playIndex):0,
    searchtopshow:localStorage.searchtopshow?JSON.parse(localStorage.searchtopshow):false,//搜索页面头部是否显示
    user:localStorage.user?JSON.parse(localStorage.user):{islogin:false},
    clickindex:1
  },
  mutations: {
    setplayList(state,val){
      state.playList = val
      localStorage.playList= JSON.stringify(state.playList)
    },
    setsearchtopshow(state,val){
      state.searchtopshow = val
      localStorage.searchtopshow= JSON.stringify(state.searchtopshow)
    },
    pushplayList(state,val){
      state.playList.push(val)
      localStorage.playList= JSON.stringify(state.playList)
    },
    setpalyIndex(state,val){
      state.playIndex = val
      localStorage.playIndex= state.playIndex
    },
    setUser (state,val){
      state.user = val
      localStorage.user= JSON.stringify(state.user)
    },
    setclickindex(state,val){
      state.clickindex = val
    }
  },
  actions: {
    // setplayList(state,val){
    //   state.playList = val
    // }
  },
  modules: {
  }
})
